<?php

namespace app\admin\controller;

use app\admin\services\CategoryService;
use app\common\controller\AdminBaseController;
use think\App;

class Category extends AdminBaseController
{
    protected $service;
    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->service = new CategoryService();
    }

    public function index()
    {
        return view('index', [
            'pid' => isset($_GET['pid']) ? $_GET['pid'] : 0
        ]);
    }

    public function add()
    {
        if ($this->request->isPost()) {
            return $this->service->add($this->params);
        }else {
            return view('add', [
                'pid' => $_GET['pid']
            ]);
        }
    }

}